<template>
  <view class="container">
    <view class="topBox">
      <image :src="userInfo.avatarUrl" mode="" class="avatar"></image>
      <view class="nickName">{{userInfo.nickName}}</view>
    </view>
    <view class="panel">
      <view class="top">
        <view class="topItem1">
          <text class="top1">8</text>
          <text class="title">收藏的店铺</text>
        </view>
        <view class="topItem1">
          <text class="top1">14</text>
          <text class="title">收藏的商品</text>
        </view>
        <view class="topItem1">
          <text class="top1">18</text>
          <text class="title">关注的商品</text>
        </view>
        <view class="topItem1">
          <text class="top1">84</text>
          <text class="title">足迹</text>
        </view>
      </view>
      <view class="middle">
        <view class="title">我的订单</view>
        <view class="main">
          <view class="mainItem">
            <image src="/static/my-icons/icon1.png" mode="widthFix" class='icon'></image>
            <view class="text">待付款</view>
          </view>
          <view class="mainItem">
            <image src="/static/my-icons/icon2.png" mode="widthFix" class='icon'></image>
            <view class="text">待收货</view>
          </view>
          <view class="mainItem">
            <image src="/static/my-icons/icon3.png" mode="widthFix" class='icon'></image>
            <view class="text">退款/退货</view>
          </view>
          <view class="mainItem">
            <image src="/static/my-icons/icon4.png" mode="widthFix" class='icon'></image>
            <view class="text">全部订单</view>
          </view>
        </view>
      </view>
      <view class="bottom">
        <view class="bottomItem">
          <view class="title">收获地址</view>
          <uni-icons type="arrowright" class='icon'></uni-icons>
        </view>
        <view class="bottomItem">
          <view class="title">联系客户</view>
          <uni-icons type="arrowright" class='icon'></uni-icons>
        </view>
        <view class="bottomItem"  @click="logout">
          <view class="title">退出登录</view>
          <uni-icons type="arrowright" class='icon'></uni-icons>
        </view>
      </view>
    </view>
  </view>
</template>

<script>
  import {
    mapState,mapMutations
  } from 'vuex';
  export default {
    name: "my-info",
    data() {
      return {

      };
    },
    computed: {
      ...mapState('user', ['userInfo']),
    },
    methods: {
      ...mapMutations('user',['UPDATEADDRESS','UPDATEUSERINFO','UPDATETOKEN']),
      async logout(){
        const [err,succ]=await uni.showModal({
          title:'提示',
          content:'确认退出登录吗？'
        }).catch(err=>err);
        if(succ&&succ.confirm){
          console.log(this);
          this.UPDATEADDRESS({});
          this.UPDATEUSERINFO({});
          this.UPDATETOKEN('');
        }
      }
    }
  }
</script>

<style lang="scss" scoped>
  .container {
    font-family: 'Times New Roman', Times, serif;
    height: 100%;
    background-color: #efefef;
    .panel{
      position: relative;
      top: -10px;
      width: 90%;
      margin: 0 auto;
      .top{
        height: 60px;
        display: flex;
        background-color: #fff;
        justify-content: space-around;
        border-radius: 10px;
        margin-bottom: 10px;
        .topItem1{
          display: flex;
          flex-direction: column;
          align-items: center;
          justify-content: center;
          font-size: 14px;
        }
      }
      .middle{
        margin-bottom: 10px;
        height: 120px;
        border-radius: 10px;
        display: flex;
        background-color: #fff;
        flex-direction: column;
        justify-content: space-around;
        .title{
          margin-left: 10px;
          font-size: 14px;
          font-weight: bold;
        }
        .main{
          display: flex;
          justify-content: space-around;
          .mainItem{
            text-align: center;
            .text{
              font-size: 13px;
            }
            .icon{
              width: 40px;
            }
          }
        }
      }
      
      .bottom{
        background-color: #fff;
        border-radius: 10px;
        .bottomItem{
          font-size: 13px;
          height: 45px;
          line-height: 45px;
          display: flex;
          justify-content: space-between;
          padding: 0 10px;
          .title{
            font-weight: bold;
          }
        }
      }
    }
    .topBox {
      height: 400rpx;
      background-color: #c00000;
      display: flex;
      justify-content: center;
      align-items: center;
      flex-direction: column;

      .avatar {
        width: 90px;
        height: 90px;
        border-radius: 45px;
        border: 2px solid #fff;
        box-shadow: 0 1px 5px black;
      }

      .nickName {
        font-size: 16px;
        color: #fff;
        font-weight: blod;
        margin-top: 10px;
      }
    }
  }
</style>
